package com.unicom.auth.kit;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.kit.StrKit;

public class ArrayKits {
	public static int[] toIntegers(String[] values){
		int[] integers=new int[values.length];
		for (int i=0;i<values.length;i++) {
			integers[i]=Integer.parseInt(values[i]);
		}
		return integers;
	}
	public static long[] toLongs(String[] values){
		long[] longs=new long[values.length];
		for (int i=0;i<values.length;i++) {
			longs[i]=Integer.parseInt(values[i]);
		}
		return longs;
	}
	public static boolean[] toBooleans(String[] values){
		boolean[] bools=new boolean[values.length];
		for (int i=0;i<values.length;i++) {
			if (values[i].equals("on")) {
				bools[i]=true;
			}else{
				bools[i]=Boolean.parseBoolean(values[i]);
			}
		}
		return bools;
	}
	public static double[] toDoubles(String[] values){
		double[] doubles=new double[values.length];
		for (int i=0;i<values.length;i++) {
			if (StrKit.isBlank(values[i])) {
				values[i]="0";
			}
			doubles[i]=Double.parseDouble(values[i]);
		}
		return doubles;
	}
	public static List<Long> toList(long[] ordergoods_id_arr) {
		List<Long> list=new ArrayList<>();
		for (int i = 0; i < ordergoods_id_arr.length; i++) {
			list.add(ordergoods_id_arr[i]);
		}
		return list;
	}
	
}
